#ifndef BASIC_H__
#define BASIC_H__

#include "../util/memory.h"

#if 0
imort std.lib;
#endif

struct CharacterLiteral { char character; };

struct CharacterLiteral* allocateCharacterLiteral(char character)
{
	struct CharacterLiteral* r = malloc(sizeof(struct CharacterLiteral));
	r->character = character;
	return r;
}

void freeCharacterLiteral(struct CharacterLiteral* f)
{
	free(f);
}

struct IntegerLiteral { int integer; };

struct IntegerLiteral* allocateIntegerLiteral(int integer)
{
	struct IntegerLiteral* r = malloc(sizeof(struct IntegerLiteral));
	r->integer = integer;
	return r;
}

void freeIntegerLiteral(struct IntegerLiteral* i)
{
	free(i);
}

struct Name { char* characters; };

struct Name* allocateName(char* characters)
{
	struct Name* r = malloc(sizeof(struct Name));
	r->characters = characters;
	return r;
}

void freeName(struct Name* f)
{
	if(f == NULL) return;
	free(f->characters);
	free(f);
}

struct NameList { struct Name* head; struct NameList* tail; };

struct NameList* allocateNameList(struct Name* head, struct NameList* tail)
{
	assert(head != NULL);

	struct NameList* r = malloc(sizeof(struct NameList));
	r->head = head;
	r->tail = tail;
	return r;
}

void freeNameList(struct NameList* f)
{
	if(f == NULL) return;
	freeName(f->head);
	freeNameList(f->tail);
	free(f);
}

struct StringLiteral { char* characters; };

struct StringLiteral* allocateStringLiteral(char* characters)
{
	struct StringLiteral* r = malloc(sizeof(struct StringLiteral));
	r->characters = characters;
	return r;
}

void freeStringLiteral(struct StringLiteral* f)
{
	free(f->characters);
	free(f);
}

#endif
